<?php
if(!defined("BO_ROOT")){
    exit("NO BO");
}
/**
 * Description of base
 *
 * @author aboc
 */

function __autoload($name){
    if(file_exists(BO_ROOT.'source/module/'.$name.'class.php')){
        include_once BO_ROOT.'source/module/'.$name.'class.php';
    }
    elseif(file_exists(BO_ROOT.'source/lib/'.$name.'.class.php')){
        include_once BO_ROOT.'source/lib/'.$name.'.class.php';
    }else{
        echo '类'.$name.'不存在';exit;
    }
}

/**
 * 各基类
 */
class bo{

    private static $_db = null;
    /**
     * 数据库类
     *
     * @return DbMysql
     */
    static function db(){
        if(self::$_db==null){
            self::$_db = new DbMysql(array(
                'dbhost' => 'localhost',
                'dbuser' => 'root',
                'dbpass' => 'root',
                'dbname' => 'test'
            ));
        }
        return self::$_db;
    }

    private static $_member = null;
    /**
     *
     * @return member
     */
    static function member(){
        if(self::$_member==null){
            self::$_member = new member();
        }
        return self::$_member;
    }

    private static $_link = null;
    /**
     *
     * @return link
     */
    static function link(){
        if(self::$_link==null){
            self::$_link = new link();
        }
        return self::$_link;
    }


    private static $_content = null;
    /**
     *
     * @return content
     */
    static function content(){
        if(self::$_content==null){
            self::$_content = new content();
        }
        return self::$_content;
    }

    private static $_comment = null;
    /**
     *
     * @return comment
     */
    static function comment(){
        if(self::$_comment==null){
            self::$_comment = new comment();
        }
        return self::$_comment;
    }

    private static $_sort = null;
    /**
     *
     * @return sort
     */
    static function sort(){
        if(self::$_sort==null){
            self::$_sort = new sort();
        }
        return self::$_sort;
    }

}

